package contants;

import cn.hutool.core.util.StrUtil;

public enum TitleEnum {

    SINGLE("【单选题】"),
    MORE("【多选题】"),
    FULL("【填空题】"),
    BOOLEAN("【判断题】"),
    SIMPLE_ANSWER("【简答题】"),
    READING("【阅读理解题】"),
    ALL_FULL("【完形填空题】"),

    ;

    private String titleType;

    TitleEnum(String titleType) {
        this.titleType = titleType;
    }

    public static TitleEnum getTypeByValue(String text) {
        if (StrUtil.isBlank(text)) {
            return null;
        }
        for (TitleEnum titleEnum : values()) {
            if (titleEnum.getTitleType().equals(text)) {
                return titleEnum;
            }
        }
        return null;
    }

    public static TitleEnum checkExists(String text) {
        if (StrUtil.isBlank(text)) {
            return null;
        }
        for (TitleEnum titleEnum : values()) {
            if (text.contains(titleEnum.getTitleType())) {
                return titleEnum;
            }
        }
        return null;
    }

    public String getTitleType() {
        return titleType;
    }
}
